const paramsMixin = {
	computed: {
		id () {
			return this.params?.id || ''
		},
		title () {
			return this.params?.title || ''
		},
		cover () {
			return this.params?.cover || (this.catalogs && this.catalogs.length > 0 ? (this.catalogs[0].cover || '') : '')
		},
		creator () {
			return this.params?.creator || ''
		},
		avatar () {
			return this.params?.avatar || this.app.$business.getDefaultAvatar(this.source)
		},
		desc () {
			return this.params?.desc || ''
		},
		latest () {
			return this.params?.latest || ''
		},
		style () {
			return this.params?.style || ''
		},
		updateTime () {
			return this.params?.updateTime || ''
		},
		tags () {
			return this.params && this.params.tag ? this.params.tag.split(',') : []
		},
		isEnd () {
			return this.params?.isEnd
		},
		isEnd () {
			return this.params?.isVip
		},
		isAdult () {
			return this.params?.isAdult
		},
		type () {
			return this.params?.type
		},
		shareUrl () {
			return this.params?.shareUrl
		},
		source () {
			return this.params?.source
		}
	},
	data () {
		return {
			params: {}
		}
	},
	created () {
		this.params = this.app.$Route.query?.params ? JSON.parse(decodeURIComponent(this.app.$Route.query.params)) : {}
	},
	methods: {
		handleCopyClick (args) {
			let params = this.params || args
			if ( !params ) return
			this.$refs.actionSheet.show({
				title: {
					text: '更多操作',
					color: this.skinColor.color_2
				},
				itemList: [{
					label: '复制标题',
					value: 'copytitle'
				},{
					label: '复制创建者',
					value: 'copycreator'
				},{
					label: '搜索标题相关',
					value: 'searchtitle'
				},{
					label: '搜索创建者相关',
					value: 'searchcreator'
				}],
				options: {
					cancel: {
						text: '关闭',
						color: this.skinColor.color_1
					},
					bgColor: this.skinColor.color_bg_2,
					color: this.skinColor.color_1,
					border: {
						color: this.skinColor.color_gap_1,
					}
				},
				success: (res) => {
					if ( res.confirm ) {
						if ( res.data.detail.value == 'copytitle' ) {
							uni.setClipboardData({
								data: params.title,
								success: function () {
									uni.showToast({
										icon: 'none',
										title: '标题已复制'
									})
								}
							})
						}
						if ( res.data.detail.value == 'copycreator' ) {
							if ( params.creator ) {
								uni.setClipboardData({
									data: params.creator,
									success: function () {
										uni.showToast({
											icon: 'none',
											title: '创建者名称已复制'
										})
									}
								})
							} else {
								uni.showToast({
									icon: 'none',
									title: '未找到创建者'
								})
							}
						}
						if ( res.data.detail.value == 'searchtitle' ) {
							this.app.$Router.push({
								path: '/pages/search/result',
								query: {keyword: params.title,type: params.type}
							})
						}
						if ( res.data.detail.value == 'searchcreator' ) {
							this.app.$Router.push({
								path: '/pages/search/result',
								query: {keyword: params.creator,type: params.type}
							})
						}
					}
				}
			})
		}
	}
}

export default paramsMixin